package web.protocols.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import domain.entities.Compromisopais;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;
import services.ProtocoloCompromisopaisService;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Guillermo
 * Date: 05/10/12
 * Time: 13:44
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/Menu")
public class MenuController extends ActionSupport {

    protected ProtocoloCompromisopaisService protocoloCompromisopaisService;
    protected String display;

    @Autowired
    public MenuController(ProtocoloCompromisopaisService protocoloCompromisopaisService) {
        this.protocoloCompromisopaisService = protocoloCompromisopaisService;
    }

    @Action(value="saveCountry")
    public void saveCountry() {

        Map session = ActionContext.getContext().getSession();
        if(!display.equals("") ){
            Compromisopais compromisopais = protocoloCompromisopaisService.getCompromisopaisByCountry(display);
            session.put("compromisopaisid", compromisopais.getId());
        }
        session.put("display", display);

    }

    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public ProtocoloCompromisopaisService getProtocoloCompromisopaisService() {
        return protocoloCompromisopaisService;
    }

    public void setProtocoloCompromisopaisService(ProtocoloCompromisopaisService protocoloCompromisopaisService) {
        this.protocoloCompromisopaisService = protocoloCompromisopaisService;
    }
}
